<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        h1::after {
            content: "前";
        }
        /* 鼠标移入H1后伪元素content发生改变 */
        
        h1:hover::after {
            /* 从行内属性获取值 */
            content: attr(data-text);
        }
    </style>
</head>

<body>
    <h1 data-text="后">鼠标移入</h1>
</body>

</html>